package com.senseuni.da

import android.content.Intent
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.elvishew.xlog.XLog
import com.google.android.material.snackbar.Snackbar
import com.senseuni.da.databinding.ActivityDebugBinding
import com.senseuni.da.http.ApiDataSource
import com.senseuni.da.utils.AESUtils
import com.senseuni.da.utils.AppUtils
import com.senseuni.da.utils.LanguageHelper
import com.senseuni.da.utils.MediaUtil
import com.senseuni.da.utils.RsaUtils
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.functions.Consumer
import org.apache.commons.lang3.RandomStringUtils
import java.io.File
import java.io.FileWriter
import java.lang.Runtime.getRuntime


class DebugActivity : AppCompatActivity() {

    private lateinit var binding: ActivityDebugBinding

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = ActivityDebugBinding.inflate(layoutInflater)
        setContentView(binding.root)
        XLog.d("onCreate")

        binding.buttonMqtt.setOnClickListener {
            val intent = Intent()
            intent.setClass(this, MqttTestActivity::class.java)
            startActivity(intent)
        }

        binding.buttonVideo.setOnClickListener {
            val intent = Intent()
            intent.setClass(this, MainActivity::class.java)
            startActivity(intent)
        }

        binding.buttonUpgrade.setOnClickListener {
            val dataSource = ApiDataSource.instance
            dataSource.checkUpgrade()
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(Consumer {
                    val intent = Intent()
                    intent.putExtra("id", it.id)
                    intent.setClass(this, UpgradeActivity::class.java)
                    startActivity(intent)
                },{

                })
        }

        binding.buttonRegistry.setOnClickListener {
        }

        binding.buttonInstallapk.setOnClickListener {
//            val intent = Intent(Intent.ACTION_VIEW);
//            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
//            val path = "/sdcard/ads_1.0.1.apk"
//            val file = File(Uri.parse(path).getPath());
//            intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
//            val uri = FileProvider.getUriForFile(applicationContext, "com.senseuni.ads.fileprovider", file);
//            intent.setDataAndType(uri, "application/vnd.android.package-archive");
//            startActivity(intent);
            AppUtils.install("/sdcard/ads_1.0.1.apk")
        }

        binding.buttonRoot.setOnClickListener {
//            val exec = getRuntime().exec("su")
            XLog.d(">>>>>>>>>>")
            XLog.d("button_get_ad_info")
            val decrypt = "H6sczpja3CjiGMRYqw5W4fv8Mjg3eRV6ErewIa3xnMZud5U11vqmPgNNC9HmBLdOskDkeG8dSUGmrra+DOGxuc5UEje/07kKpWpWcAdZ9QTEbK8xQwLKb3mWpB+VAIRDFjVdofMXfhhCKzlHG2FDmUZ1KN2KA7iea1SLnt3hYvE="
//            val srcKey = RsaUtils.decryptByPublicKey(MediaUtil.PUBLIC_KEY, decrypt)
//            XLog.d("解密后的Key:$srcKey")

            var base64 = "piFMqlzgHsYCyY2UcKXqqjL7b+0ONY5nCKYR77kAB7ofwdxWsmxyaOliTQvAB0OmAPFF0utss5GnLqp9RY5wmulzFz+IHl7MbFO81kFQItyeJE74+TD1pBQuaLjye5NXoZ+gpqQSb2UeEx7BvUefI5y0P1mFzSpDqRDuSRMjSsFGAH+NtYPR9ARsEIqJeHguS4+lpKnFHRkg5G2Cq62BQToLrZspE9RVRsbv72/DE0SqYp8PB/9QMGUL1m8NotvuiYj2JgSoxl5+P8VV04Ur+iIBpak7g3GFKZuuyzHzH6bTVM9lCF4vmh0NDlIiQxliwxeQtVgJr2sqmgRBMlVzornwhvU16iAZhPPzRs8qgG6UBQBjnLvYpeTg7SvyIC0p4/qMwbAbJ5GjscdNNk64zN54G3+8RLkCm0mdPSpcJ9m6A6nFx/SXKn7llGHxc8IZkUC6zcaPvzu9IAqgCQNV2xVa8rulfUbo5KnBJMMjZCwwJKiqcInbkeGLRAEDiwQU9lhg2+Qjx5c8nPinZZgm4irFq1J4bWf7Qb5zyCvwOPBz39NlDQKEaCBPyiKMB7N9Wwvo3y2m+XKQ2bvJHDeJDv7v6UGm7pLKXVNl8OMWOUeeR7yurSC61XsEb6ItHRiVDve6R44mAd14cxRQQxvO7O/3M7hM6VmPAbPdzJIk4mvC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IOXeRlRvB0lV7ODHY2ymEQHcNdaSJVpBP0qzMqSTeBIgNO+YJ2PRCuAfRvE38sXzTlcrxIw3EHcclRkM4dy6Gwb/YOSjy7nsGCat3aFPFUc2RU3DcxMn2OZFP/exe0psYRReoEv7sUVLaXbaAnezzWX3/YeJ2MskuekOFmXAONYZZVA7AxVcKAT7pHJbfz0fDucIpAL0KHxWvNiSoUErJ+BtsVtpiAn1D/pSs/pDchBdwniY3GFyUJRGtMbTIchP7X5tXI0JF05Bx8Zb0tqgJkryEJ1HUP7Eikh5UvKhlaIxj5TJq6wQK2K4Yvujk/HDE8kc7cGDd7j0J+0BMJlbDCLay3U1s8LgULFOeKiW0uvuhfwk/xAEJywAyej2VjnzZoMmdolEiAhO4fz+VyBueb8G2/SqsCNNv5xEudBSDmzaUvBREI2UnZPyLOi0Lrz45rhcPsPRtL8j7v4YY0Tg==";
//            base64 = AESUtils.decrypt(base64, srcKey)
            XLog.d(base64)
            base64 = MediaUtil.decrypt(base64, decrypt)

            MediaUtil.convertBase64ToImage(base64, "/sdcard", null);

        }

        binding.buttonGetImei.setOnClickListener {
            val imei = AppUtils.getImei(this)
            if (imei.isNullOrEmpty()) {
                Snackbar.make(binding.root, "未获取到IMEI", Snackbar.LENGTH_SHORT).show()
            } else {
                Snackbar.make(binding.root, "IMEI=${imei}", Snackbar.LENGTH_SHORT).show()
            }
        }

        binding.buttonGetAdInfo.setOnClickListener {
            XLog.d("button_get_ad_info")
            val decrypt = "H6sczpja3CjiGMRYqw5W4fv8Mjg3eRV6ErewIa3xnMZud5U11vqmPgNNC9HmBLdOskDkeG8dSUGmrra+DOGxuc5UEje/07kKpWpWcAdZ9QTEbK8xQwLKb3mWpB+VAIRDFjVdofMXfhhCKzlHG2FDmUZ1KN2KA7iea1SLnt3hYvE="
            val srcKey = RsaUtils.decryptByPublicKey(RsaUtils.publicKey, decrypt)
            XLog.d("解密后的Key:$srcKey")
        }

        binding.buttonSystemReboot.setOnClickListener {
            AppUtils.reboot()
        }

        binding.buttonAppReboot.setOnClickListener { AppUtils.rebootApp() }

        binding.buttonScreenOn.setOnClickListener { AppUtils.screenOn() }

        binding.buttonScreenOff.setOnClickListener { AppUtils.screenOff() }

        binding.buttonLanguageCn.setOnClickListener {
            LanguageHelper.switchCN()
        }

        binding.buttonLanguageEn.setOnClickListener {
            LanguageHelper.switchEN()
        }

        binding.buttonLanguageId.setOnClickListener {
//            LanguageHelper.switchID()
            XLog.d(">>>>>>>>>>>>>>>>")
            val keyPair: RsaUtils.RsaKeyPair = RsaUtils.generateKeyPair()
            XLog.d("私钥：" + keyPair.getPrivateKey())
            XLog.d("公钥：" + keyPair.getPublicKey())

            val srcKey = RandomStringUtils.random(16, "abcdefghijklmnopqrstuvwxyz1234567890")
            XLog.d("随机key:$srcKey")

            val encryptKey: String = RsaUtils.encryptByPublicKey(keyPair.getPublicKey(), srcKey)
            XLog.d("加密后:$encryptKey")

            val decryptByPrivateKey: String =
                RsaUtils.decryptByPrivateKey(keyPair.getPrivateKey(), encryptKey)
            XLog.d("解密后的Key：$decryptByPrivateKey")

            val encryptByPrivateKey: String =
                RsaUtils.encryptByPrivateKey(keyPair.getPrivateKey(), decryptByPrivateKey)
            XLog.d("加密后的Key：$encryptByPrivateKey")

            val decryptKey: String =
                RsaUtils.decryptByPublicKey(keyPair.getPublicKey(), encryptByPrivateKey)
            XLog.d("解密后的Key：$decryptKey")

            val base64 = MediaUtil.convertImageToBase64("/sdcard/1.jpg")
            val encryptBase64 = AESUtils.encrypt(base64, srcKey)

            val decryptBase64 = AESUtils.decrypt(encryptBase64, decryptKey)

            val newBase64 = AppUtils.removeBase64Header(decryptBase64)

            val result = MediaUtil.convertBase64ToImage(newBase64, "/sdcard/", null)

        }

        binding.buttonGetAdInfo.setOnClickListener {
            val base64 = AppUtils.convertImageToBase64("/sdcard/1.jpg")
            val encrypt = MediaUtil.encrypt(base64)
            XLog.d("key:" +encrypt[1])
            //写文件
            var path2 = "/sdcard/2.txt";
            var path3 = "/sdcard/3.txt";
            val file = File("/sdcard", "2.txt") // 或者指定其他路径
            val writer = FileWriter(file)
            writer.write(encrypt[0])
            writer.close()

            val file2 = File("/sdcard", "3.txt") // 或者指定其他路径
            val writer2 = FileWriter(file2)
            writer2.write(encrypt[1])
            writer2.close()
        }

//        XXPermissions.with(this)
//            .permission(Permission.Group.STORAGE)
//            .permission(Permission.SYSTEM_ALERT_WINDOW)
//            .permission(Permission.REQUEST_INSTALL_PACKAGES)
//            .request(object : OnPermissionCallback {
//                override fun onGranted(permissions: List<String>, allGranted: Boolean) {
//                    Logger.d("Storage Permission is granted")
//                }
//
//                override fun onDenied(permissions: List<String>, doNotAskAgain: Boolean) {
//                    if (doNotAskAgain) {
//                        Logger.d("Storage permission onDenied,please manual setting")
//                    } else {
//                        Logger.d("get storage permission failed")
//                    }
//                }
//            })
    }


}